import codecs

def toGb2312(file_path):
    """
    将.c/.h文件转成GB2312的编码格式
    Args:
        file_path (string): 文件路径
    """
    # 打开待转换文件并指定当前编码格式为UTF-8
    with codecs.open(file_path, 'r', encoding='utf-8') as file:
        content = file.read()
    # # 将文件内容按照GB2312编码格式进行编码
    gb2312_content = content.encode('gb2312')
    # 写入到新的文件中
    output_file_path = file_path
    with codecs.open(output_file_path, 'w', encoding='gb2312') as output_file:
        output_file.write(gb2312_content)

toGb2312('hk32t010_conf.h')